# Every update requires an update of these hashes and the version within the control file of each of the 32 ports.
# So it is probably better to have a central location for these hashes and let the ports update via a script
set(QT_MAJOR_MINOR_VER 5.15)
set(QT_PATCH_VER 10)
set(QT_UPDATE_VERSION 0) # Switch to update qt and not build qt. Creates a file cmake/qt_new_hashes.cmake in qt5-base with the new hashes.

set(QT_PORT_LIST base 3d activeqt charts connectivity datavis3d declarative gamepad graphicaleffects imageformats location macextras mqtt multimedia networkauth
                 purchasing quickcontrols quickcontrols2 remoteobjects script scxml sensors serialport speech svg tools virtualkeyboard webchannel websockets
                 webview winextras xmlpatterns doc x11extras androidextras translations serialbus webengine webglplugin wayland)

set(QT_HASH_qt5-3d               6c3d94b02188493567921552e104f407fd92bf2b95acd6c933a9dd214ba7ebc0c1983ffcaefeae63d60131d02651df1da834522628711d36514dc697e7bb885f)
set(QT_HASH_qt5-activeqt         67ebe2eb0b45c128d9e57305f378900d21348d75960800e7848134452c1c01688219b36e712bceff76e942ce05e5100881194409627a7902a6d613938656550b)
set(QT_HASH_qt5-androidextras    9001f6cee644efcbfe5df1a7f97e8426364cc1a86cc7b5ae897aed05436920992325c8ff708a4de796ae02ab38af5c6cc20388f5d682bcd7fd43aa8d5775c5ae)
set(QT_HASH_qt5-base             94ac739d76dd9fff54cde46e818fee6c6763f8b207b759108455febff84c9dfeb48ea7807451d7248cbfd8af24c2a1263c34dcbd2be055136e39325e32725eef)
set(QT_HASH_qt5-charts           15c76bc6b987b2d89473972df9cd4826913bb0dd2dffdb06fc6dfdbdd1a5676508584d5f0982b06ab513e46cee12871f3eb0ed00f94fccf23ef807079be96961)
set(QT_HASH_qt5-connectivity     3bc1c701f1e80794a410f0784c8955be42cb800c315d686da1a1e8429dbb72799bba2da59592f9edcd686c326df26fee4bf4e74b49feb96119e6aa29e982059f)
set(QT_HASH_qt5-datavis3d        414f4c86a55a9f2db745691f01f0d7ad6bbdddf56a04a280fd11f5b1bcd590ff34a8b35e178eaef15e1b1a1813cb148ac5bddfbb8fcb05de6ed5492666cccaf9)
set(QT_HASH_qt5-declarative      378fc41a31edb52d85fd5e37fe6c086e35b5d5d759ceacc49cf7981a8a38d25ae5f2ca27d99547bd1db381f32128e7947800e2a01a857177707cc2a9980373a8)
set(QT_HASH_qt5-doc              5c2751c1736c1c6818a7806ed14a81856115dfd8f46508dcea9b8023df638d34e96171c383cbdd3b7c307f97297e97da13503032225d8135e1a52b2fef5722e8)
set(QT_HASH_qt5-gamepad          20f06a11b8e7057e11b2f061ba088f1721cf94a20bed21e52eb0d7c6e20cd8f74ae2d0fe47748466c4a3dd63f9843afc94f74fb3076849e80ad8e71017fb3605)
set(QT_HASH_qt5-graphicaleffects a7e1326c10bd3bbce0f5b3e664dc42e5573de7add44ac852417aba9170a4e21c173679a65ea4ed403782fa954652b896266611887664488a99d42a8b3c8f7504)
set(QT_HASH_qt5-imageformats     7373884e5f01da0aae6f7d4575ca953de3be6cd41d3d19aa29bb2a2e5998486407525f23122e8b13c26143e64aa95d4756c5381643e93f930472c9890e6561de)
set(QT_HASH_qt5-location         e4fb56ddd2dc50024f02de84323c3299788eb6632672e1bc52ef1399ccf9d0af34b0104548cb108fb372870057426b0cdd52052ad91ba45fc7f8098a675f29a4)
set(QT_HASH_qt5-macextras        6eea905dab769183bacba4eac04f8de9c006dfda2034bd2025361445781a5379b2cc038ca6af95206f52fe6a2a11d73b36f96b0b716e93445973b9fb20337167)
set(QT_HASH_qt5-mqtt             5ca3b7ab7865f09eb0d5d300854b9fc7cd1534090a17462fcdbecee25f831e8d3a0de2adb151ae6f810f9df0ef30146f22a902275636554f6b77660e9bf00440)
set(QT_HASH_qt5-multimedia       a322dba0daced00cf0a7fcd21b7f55c281dec107b7976792406ecc7658c94ea1a40c81c7cbdc0987f1be32cafd2458993c92db87fcbfdc7ba1243d2e0047896e)
set(QT_HASH_qt5-networkauth      bfdda139223d183767e50fb95309dee7cd85c42fa09a00246a38987bf1570d84a137fb3fc71119416cc45126f21f6964f430b031e5acd4447caf30d0aac3bc2a)
set(QT_HASH_qt5-purchasing       9758325cf7bbdc8428a1ec9254749c27d6397a72d4fe164dc8ce0da08d09aa9c0ec0edb67879d6aa54500a47096154b252292b200d0bc516de425bfaad4f9ca8)
set(QT_HASH_qt5-quickcontrols    fe7faf770adad9820ae897b5822b5dcba095dfc267411dd92d0b46daf7f84f87b3d9f2f9f90a90c030b09dcdc30549647f3f42039ac09e9207b5c1462116ed10)
set(QT_HASH_qt5-quickcontrols2   87e1590223c36b1191f4d976cab946c7d688228032a4a32e699a87ee844d64ed60f93c3c0c148374f4ac6ca619bbf583492cb9b57823b15dd0b9811ca270f390)
set(QT_HASH_qt5-remoteobjects    980884aaa65cd3462d9359f4def9e15a1d395569a14ee6c7c70f71a3d0445031baaa5a91541df01d6b7d6ca48bade2ae2c4ceebb306a97eefdc500c2f7d3eee6)
set(QT_HASH_qt5-script           3748cc8c90c2f96a21e6b0c8ffacca11d023e37091f6f5a05608f7f787f81619a7aac5c8074360486e28033a28601c1d347e499bc387a36f50c4cec2be30e782)
set(QT_HASH_qt5-scxml            93e2df05da176802a0439ba752f52d1c84d291a2addf9492aaab2099f06efb32d896edd0660711bb2e0b67f7a9ea2c4d31b4ec3366f6230140d3de0056478923)
set(QT_HASH_qt5-sensors          9950b0f8b90727a051299c5b7e7852819c165bcdb1cbe2f8bd7386768175c387ab838918e7d6f1dcf2a7d6d32bb1559dfda225c57e8b9b5b4ffeac5f3db432ac)
set(QT_HASH_qt5-serialbus        914a6ec2d51f89f84bc3425185cc35d497595c8f5378ff475ce784bc744fe1a9054feeaeed8d4205abc5f4de256d9511e8e1be3076066eed424848724325f513)
set(QT_HASH_qt5-serialport       59face48cce750fb02c112dbef9c997a5b61d84cf8085a0f8c59c3bb5c93d7110de9c9830f26f3ed61fffb2c23eb8a42d5683211abaa6e5147cf87643469a45e)
set(QT_HASH_qt5-speech           b938c8baba11aa9a40a2ec5492df32c511164686aa2649d78023beccc8b23f1e0a77193672f7bc7d7f72aeb7b59fe30972683f5a4e22e1e39da9744ecd40201d)
set(QT_HASH_qt5-svg              6de19c1dd6584f95bc3abbd391495bbdc13f15cc677a0c9e7afa2a0beffef8f8128eab5ccda741ed95af4553203b9daf1fc0327197912945e7211aeace33c6e7)
set(QT_HASH_qt5-tools            08d5182309c0f19f14af4e509871bca13b89cdd762bd4b7f98b15120b2e74308e478f826b4236f01abc299520da32b716df9e7bfaa84935fbdc0a74422ade5f1)
set(QT_HASH_qt5-translations     94f22857cf9f14f13f774ee5632bfd0fc367ca5fb745cbfb3997fee8651961d9547f0a629afc54c35b2e4493244da9b94214777e20340c2b203c538bc1c84a22)
set(QT_HASH_qt5-virtualkeyboard  6d539af5e5a336f2bf4ac1e6006268e50b426f6bb174019f742847da86f8cd5c8eb2c5f353255b5d1bba9c9c7a7b035bcb12e0063be5b31e45741ea9bd478582)
set(QT_HASH_qt5-wayland          214b1fec7dfd815d148a7485f7811e623b06d172e58e4ee3167264a4e4b8f4aeec11474e574f91652a0bd3a48476a6747cad468f1e5035c49a55a96fc1400899)
set(QT_HASH_qt5-webchannel       ed8349820c623dd7abcd34244a2f05426667d6997a8952567c3cbe785bb2ea92f03dd931bb53f77b34faff16d04dd7d39e4165c75d7a9ebb4ae225d7582355bc)
set(QT_HASH_qt5-webengine        e35d0cab5f66a148420206616b3517e62b8320572beac53650096c0db58db8b4942d52a3abf4f0d6db1450de27befeb92f8b632c1277b0939464c1407a904b1b)
set(QT_HASH_qt5-webglplugin      f47dc98f94ee422bdfce70663e24af3155047cb3ee1a914cb4d5f0d269de43bdb5f68376e04d0a9701c2f95ffe19c29f5c38db6441ec2144ccb41beb45924f1e)
set(QT_HASH_qt5-websockets       b9a2593169f0ff8e3e77c178de689dacfed564b2100ae67194f3636bf6d2300be3531a01b7158b06657f4a2d2a32453a98b96c6ab13fb9d8094e7ceeb5fdcbe3)
set(QT_HASH_qt5-webview          258e2146a74083b2a7e48f8875f601df8f6135cdd4bb7c35c3d8b61bec0e5937942e74c36e971565ced9c070e3f1303a3950b7f2a87b148e8abb516bd0ce7a25)
set(QT_HASH_qt5-winextras        dec47ca62e83a0794dc2f096a6fdccc45a1e43912af7f8a67ffd4aaed047d1887c85e411daba8a5a71d38e4ed3fbef1e2142a314aee1416a3a91a75c61f58706)
set(QT_HASH_qt5-x11extras        460345ad1fc7812a5bc71c097eb31c37a94acaaf94a79cfbfe3317142b4c515832ce2bf46b9bfcc9c9f669587a76492fb172dd55bfc27ca1570780772438f8b7)
set(QT_HASH_qt5-xmlpatterns      308203fafdd572998563a30b3289002f848c05b6de5a18545dc06489f97aa197c32f37019880b068c152e678ff5254ebe33333b581572811111c45a5ccb4a243)

if(QT_UPDATE_VERSION)
    message(STATUS "Running Qt in automatic version port update mode!")
    set(_VCPKG_INTERNAL_NO_HASH_CHECK 1)
    if("${PORT}" MATCHES "qt5-base")
        function(update_qt_version_in_manifest _port_name)
            set(_current_control "${VCPKG_ROOT_DIR}/ports/${_port_name}/vcpkg.json")
            file(READ ${_current_control} _control_contents)
            #message(STATUS "Before: \n${_control_contents}")
            string(REGEX REPLACE "\"version.*\": \"[0-9]+\.[0-9]+\.[0-9]+\",\n" "\"version\": \"${QT_MAJOR_MINOR_VER}.${QT_PATCH_VER}\",\n" _control_contents "${_control_contents}")
            string(REGEX REPLACE "\n  \"port-version\": [0-9]+," "" _control_contents "${_control_contents}")
            #message(STATUS "After: \n${_control_contents}")
            file(WRITE ${_current_control} "${_control_contents}")
            configure_file("${_current_control}" "${_current_control}" @ONLY NEWLINE_STYLE LF)
        endfunction()

        update_qt_version_in_manifest("qt5")
        foreach(_current_qt_port_basename ${QT_PORT_LIST})
            update_qt_version_in_manifest("qt5-${_current_qt_port_basename}")
        endforeach()
    endif()
endif()
